package com.xuan.xwaterfall.activity;

import java.util.ArrayList;
import java.util.List;

import android.util.Log;
import android.view.View;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.LinearLayout;

import com.xuan.xwaterfall.R;
import com.xuan.xwaterfall.component.ImageWaterFall;
import com.xuan.xwaterfall.util.ShareValue;

public class MainActivity extends BaseActivity {
	String TAG = "MainActivity";
	private List<String> imgs = new ArrayList<String>();
	private ImageWaterFall iwf;
	private LinearLayout llContent;
	private Button btDelete,btRefrash,btInseart;

	@Override
	public int getLayoutId() {
		// TODO Auto-generated method stub
		return R.layout.activity_main;
	}

	@Override
	public void setUI() {
		// TODO Auto-generated method stub
			WindowManager wm = getWindowManager();
			ShareValue.imgWidth = wm.getDefaultDisplay().getWidth() / 3;
		
		llContent = (LinearLayout)findViewById(R.id.llContent);
		btDelete = (Button)mFindViewAndSetOnClick(R.id.btDelete);
		btRefrash = (Button)mFindViewAndSetOnClick(R.id.btRefrash);
		btInseart = (Button)mFindViewAndSetOnClick(R.id.btInseart);
		initImage();
		iwf = new ImageWaterFall(this, imgs);
		llContent.addView(iwf);
		iwf.notifyDataSetChanged();
		
		iwf.setPositionCacheNum(18);//设置加载View时正向的缓存的View的数量
		iwf.setOppositeCacheNum(18);//设置加载View时反向的缓存的View的数量
	}

	@Override
	public void OnClickListener(View view) {
		// TODO Auto-generated method stub
		Log.v(TAG, "OnClickListener");
		switch(view.getId()){
		case R.id.btRefrash:
			imgs.set(1, "http://g.hiphotos.baidu.com/image/pic/item/1ad5ad6eddc451da9f2e8e8cb5fd5266d11632f8.jpg");
			iwf.notifyDataSetChanged();
			break;
		case R.id.btDelete:
			imgs.remove(1);
			iwf.notifyDataSetChanged();
			break;
		case R.id.btInseart:
			imgs.add(1, "http://h.hiphotos.baidu.com/image/pic/item/810a19d8bc3eb1350c58efbca41ea8d3fd1f441d.jpg");
			iwf.notifyDataSetChanged();
			break;
		}
	}

	public void initImage() {
		imgs.add("http://b.hiphotos.baidu.com/image/h%3D200/sign=5300da704990f6031bb09b470913b370/08f790529822720ed571b4bb78cb0a46f21fab30.jpg");
		imgs.add("http://d.hiphotos.baidu.com/image/pic/item/c75c10385343fbf209933523b27eca8065388f77.jpg");
		imgs.add("http://c.hiphotos.baidu.com/image/pic/item/0823dd54564e9258c34d3c9b9f82d158ccbf4e4d.jpg");
		imgs.add("http://h.hiphotos.baidu.com/image/pic/item/241f95cad1c8a7861e109e076509c93d70cf5085.jpg");
		imgs.add("http://h.hiphotos.baidu.com/image/pic/item/9345d688d43f8794e38bfa33d01b0ef41bd53ab2.jpg");
		imgs.add("http://d.hiphotos.baidu.com/image/pic/item/a8773912b31bb0514357ca2a357adab44aede045.jpg");
		imgs.add("http://e.hiphotos.baidu.com/image/pic/item/03087bf40ad162d96e7ed00113dfa9ec8a13cd1f.jpg");
		imgs.add("http://e.hiphotos.baidu.com/image/pic/item/0df431adcbef7609a7782a822cdda3cc7cd99eb8.jpg");
		imgs.add("http://g.hiphotos.baidu.com/image/pic/item/203fb80e7bec54e7c074a703bb389b504fc26a17.jpg");
		imgs.add("http://h.hiphotos.baidu.com/image/h%3D200/sign=da419bbf4510b912a0c1f1fef3fdfcb5/8326cffc1e178a82ae51a3a4f403738da977e841.jpg");
		imgs.add("http://c.hiphotos.baidu.com/image/pic/item/7acb0a46f21fbe09310b1f1069600c338744ad59.jpg");
		imgs.add("http://f.hiphotos.baidu.com/image/pic/item/bf096b63f6246b60515b6e70e9f81a4c510fa259.jpg");
		imgs.add("http://d.hiphotos.baidu.com/image/pic/item/b8014a90f603738db227d026b11bb051f819ec41.jpg");
		imgs.add("http://f.hiphotos.baidu.com/image/pic/item/b8014a90f603738d24634f7db01bb051f819ec40.jpg");
		imgs.add("http://h.hiphotos.baidu.com/image/pic/item/8718367adab44aedb9a9febbb01c8701a08bfb8e.jpg");
		imgs.add("http://c.hiphotos.baidu.com/image/pic/item/267f9e2f07082838ed44cda7bb99a9014c08f13c.jpg");
		imgs.add("http://h.hiphotos.baidu.com/image/pic/item/f9198618367adab4adb10af088d4b31c8701e424.jpg");
		imgs.add("http://h.hiphotos.baidu.com/image/pic/item/ac345982b2b7d0a213987e5cc9ef76094a369a99.jpg");
		imgs.add("http://a.hiphotos.baidu.com/image/pic/item/8cb1cb13495409230518917e9058d109b3de49b9.jpg");
		imgs.add("http://e.hiphotos.baidu.com/image/pic/item/d788d43f8794a4c2e130e0220df41bd5ad6e39a3.jpg");
		imgs.add("http://h.hiphotos.baidu.com/image/pic/item/b8389b504fc2d56282eb98eae51190ef77c66cd1.jpg");
		imgs.add("http://f.hiphotos.baidu.com/image/pic/item/622762d0f703918f2d7997ad533d269759eec429.jpg");
		imgs.add("http://b.hiphotos.baidu.com/image/pic/item/35a85edf8db1cb13702c6a52de54564e92584b2d.jpg");
		imgs.add("http://c.hiphotos.baidu.com/image/pic/item/91529822720e0cf30da618ba0946f21fbe09aa1a.jpg");
		imgs.add("http://d.hiphotos.baidu.com/image/pic/item/bd3eb13533fa828b453062b4fe1f4134970a5a52.jpg");
		imgs.add("http://e.hiphotos.baidu.com/image/pic/item/3ac79f3df8dcd10066ff293d718b4710b9122f4f.jpg");
		imgs.add("http://g.hiphotos.baidu.com/image/pic/item/bd3eb13533fa828bd0c99017ff1f4134960a5a5f.jpg");
		imgs.add("http://c.hiphotos.baidu.com/image/pic/item/adaf2edda3cc7cd987b16cde3b01213fb80e911c.jpg");
		imgs.add("http://g.hiphotos.baidu.com/image/pic/item/18d8bc3eb13533faa4362133aad3fd1f41345b2e.jpg");
		imgs.add("http://g.hiphotos.baidu.com/image/pic/item/bd3eb13533fa828b80b720feff1f4134970a5a12.jpg");
		imgs.add("http://d.hiphotos.baidu.com/image/pic/item/50da81cb39dbb6fdf147e5940a24ab18972b3767.jpg");
		imgs.add("http://g.hiphotos.baidu.com/image/pic/item/3c6d55fbb2fb4316c368c86722a4462309f7d3bc.jpg");
		imgs.add("http://f.hiphotos.baidu.com/image/pic/item/5d6034a85edf8db1de2fce790b23dd54564e74ad.jpg");
		imgs.add("http://f.hiphotos.baidu.com/image/pic/item/241f95cad1c8a7862439b5596409c93d70cf5052.jpg");
		imgs.add("http://c.hiphotos.baidu.com/image/pic/item/37d12f2eb9389b50b56a5d4f8735e5dde7116e12.jpg");
		imgs.add("http://d.hiphotos.baidu.com/image/pic/item/a1ec08fa513d2697a23709ef56fbb2fb4216d898.jpg");
		imgs.add("http://d.hiphotos.baidu.com/image/pic/item/32fa828ba61ea8d386a275b6940a304e241f58fb.jpg");
		imgs.add("http://a.hiphotos.baidu.com/image/pic/item/728da9773912b31b30187f348418367adab4e1b3.jpg");
		imgs.add("http://h.hiphotos.baidu.com/image/pic/item/622762d0f703918f57513c78523d269758eec484.jpg");
		imgs.add("http://e.hiphotos.baidu.com/image/pic/item/c83d70cf3bc79f3d0cf21b67b9a1cd11728b2952.jpg");
		imgs.add("http://c.hiphotos.baidu.com/image/pic/item/58ee3d6d55fbb2fbf97f171f4d4a20a44623dc63.jpg");
		imgs.add("http://a.hiphotos.baidu.com/image/pic/item/a08b87d6277f9e2fe7b41cba1c30e924b999f3fb.jpg");
		imgs.add("http://h.hiphotos.baidu.com/image/pic/item/eaf81a4c510fd9f9c09754db262dd42a2934a4fb.jpg");
		imgs.add("http://d.hiphotos.baidu.com/image/pic/item/9d82d158ccbf6c81037f3d5bbf3eb13533fa403c.jpg");
		imgs.add("http://a.hiphotos.baidu.com/image/pic/item/0ff41bd5ad6eddc4e187a5483adbb6fd52663324.jpg");
		imgs.add("http://b.hiphotos.baidu.com/image/pic/item/08f790529822720ed571b4bb78cb0a46f21fab30.jpg");
		imgs.add("http://h.hiphotos.baidu.com/image/pic/item/a9d3fd1f4134970a7f20466e96cad1c8a7865d1b.jpg");
		imgs.add("http://f.hiphotos.baidu.com/image/pic/item/d6ca7bcb0a46f21fa38c4fe0f5246b600d33aecc.jpg");
		imgs.add("http://h.hiphotos.baidu.com/image/pic/item/0eb30f2442a7d933e7706614ae4bd11372f001f8.jpg");
		imgs.add("http://e.hiphotos.baidu.com/image/pic/item/f603918fa0ec08fa25969fc15aee3d6d54fbdac6.jpg");
		imgs.add("http://img5.duitang.com/uploads/item/201404/10/20140410094626_Wwnam.jpeg");
	}

}
